// @FileName  :up.c
// @Time      :2024/2/29 22:35
// @Author    :YKW
//# include <bits/stdc++.h>
//using namespace std;
# include <stdio.h>
# include <stdlib.h>
# include <math.h>
# include <string.h>
# include <stdlib.h>

void solve() {
    int n;
    char bu[100000];
    scanf("%s", bu);
    n = strlen(bu);
    int max[n];
    for (int i = 0; i < n; ++i)
        max[i] = 1;
    for (int i = 1; i < n; ++i)
        for (int j = 0; j < i; ++j)
            if (bu[j] <= bu[i] && max[j] >= max[i])
                max[i] = max[j] + 1;
    int j = -1;
    for (int i = 0; i < n; ++i)
        if (max[i] > j)
            j = max[i];
    printf("%d\n", j);
}

void main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) solve();
    return 0;
}